#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "common.h"
#include "html-lib.h"

#define SEPARATOR_IN_LINE printf("&nbsp&nbsp&nbsp");\
			  printf("&nbsp&nbsp&nbsp");

void common_head(void) {
	h1("<p align=center>System Monitor");
	printf("<h2>");
	printf("<a href=\"main.cgi?%s=%s\">read only item</a>",SUB1,SUB1_READONYL);
	SEPARATOR_IN_LINE
	printf("<a href=\"main.cgi?%s=%s\">read/write item</a>",SUB1,SUB1_READWRITE);
	SEPARATOR_IN_LINE
	printf("<a href=\"main.cgi?%s=%s\">file manage</a>",SUB1,SUB1_FILEMANAGE);
	printf("</h2>");
}


void common_sub1(char* sub1) {
	if(strncmp(SUB1_READONYL,sub1,strlen(SUB1_READONYL)) == 0) {
		printf("<h3>");
		printf("<a href=\"readonly.cgi?%s=%s\">cpu</a>",SUB2,SUB2_CPU);	
		SEPARATOR_IN_LINE
		printf("<a href=\"readonly.cgi?%s=%s\">memory</a>",SUB2,SUB2_MEMORY);
		SEPARATOR_IN_LINE
		printf("<a href=\"readonly.cgi?%s=%s\">system version</a>",SUB2,SUB2_SYSVERSION);
		SEPARATOR_IN_LINE
		printf("</h3>");
	}
	else if(strncmp(SUB1_READWRITE,sub1,strlen(SUB1_READWRITE)) == 0) {
		printf(SUB1_READWRITE);
	}
	else if(strncmp(SUB1_FILEMANAGE,sub1,strlen(SUB1_FILEMANAGE)) == 0) {
		printf(SUB1_FILEMANAGE);
	}
}
